


import random
from app.utils.common_util import get_time_now



def gen_trans_id(rand_len=5, prefix=''):
    rand_no_len = rand_len
    # rand_1st = ''.join(random.sample(['0','1','2','3','4','5','6','7','8','9'], 8))
    rand_no = ''.join(random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], rand_no_len))
    time_no = get_time_now(type=3)  # 17位
    trans_id = f'{prefix}{time_no}{rand_no}'
    #print("trans_id: %s" % order_no)
    return trans_id

def gen_order_no(rand_len=3):
    rand_no_len = rand_len
    # rand_1st = ''.join(random.sample(['0','1','2','3','4','5','6','7','8','9'], 8))
    rand_no = ''.join(random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], rand_no_len))
    time_no = get_time_now(type=3)  # 17位
    order_no = time_no + rand_no
    print("order_no: %s" % order_no)
    return order_no



def rand_no():
    rand_no_len = 10
    # rand_1st = ''.join(random.sample(['0','1','2','3','4','5','6','7','8','9'], 8))
    rand_no = ''.join(random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], rand_no_len))
    time_no = get_time_now()  # 14位
    full_no = time_no + rand_no
    # print("random phone: %s" % phone)
    return full_no
